<?php
$inputStuID = isset($_GET['inputStuID']) ? $_GET['inputStuID'] : '';
$inputStuName = isset($_GET['inputStuName']) ? $_GET['inputStuName'] : '';
$selectStudent = isset($_GET['selectStudent']) ? $_GET['selectStudent'] : 1;
if ($inputStuID == '' && $inputStuName == '') {
    die('请输入查询信息');
}
require_once 'smarty/Smarty.class.php';
require_once 'SearchSFXY.php';
require_once 'SearchTSXY.php';
$smarty = new Smarty();
$inputStuIDMD5=md5($inputStuID);
$inputStuNameMD5=md5($inputStuName);
switch ($selectStudent) {
    case 1:
        if (!$smarty->isCached('showSFXY.html', $inputStuIDMD5) || !$smarty->isCached('showSFXY.html', $inputStuNameMD5)) {
            $searchSFXY = new SearchSFXY();
            $result = null;
            if ($inputStuID != '') {
                $result = $searchSFXY->user_selectID($inputStuID);
            } else {
                $result = $searchSFXY->user_selectName($inputStuName);
            }
            count($result)>0?:die('无此学生');
            $smarty->assign('result', $result);
        }
        break;
    case 2:
        if (!$smarty->isCached('showTSXY.html', $inputStuIDMD5) || !$smarty->isCached('showTSXY.html', $inputStuNameMD5)) {
            $SearchTSXY = new SearchTSXY();
            $result = null;
            if ($inputStuID != '') {
                $result = $SearchTSXY->user_selectID($inputStuID);
            } else {
                $result = $SearchTSXY->user_selectName($inputStuName);
            }
            count($result)>0?:die('无此学生');
            $smarty->assign('result', $result);
        }
        break;
}

$smarty->caching = true;
$smarty->setCacheDir('cache');
$smarty->cache_lifetime = 60;
switch ($selectStudent) {
    case 1:
        if ($inputStuID != '') {
            $smarty->display('showSFXY.html', $inputStuIDMD5);
        } else {
            $smarty->display('showSFXY.html', $inputStuNameMD5);
        }
        break;
    case 2:
        if ($inputStuID != '') {
            $smarty->display('showTSXY.html', $inputStuIDMD5);
        } else {
            $smarty->display('showTSXY.html', $inputStuNameMD5);
        }
        break;
}
